package com.nbsaas.boot.evaluate.rest.convert;

import com.nbsaas.boot.entity.evaluate.EvaluateReply;
import com.nbsaas.boot.evaluate.api.domain.request.EvaluateReplyRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.entity.evaluate.EvaluateReply;
            import com.nbsaas.boot.jpa.data.entity.User;
            import com.nbsaas.boot.entity.evaluate.Evaluate;
            import com.nbsaas.boot.jpa.data.entity.User;

/**
* 评价回复请求对象转换成实体对象
*/

public class EvaluateReplyEntityConvert  implements Converter<EvaluateReply, EvaluateReplyRequest> {

    @Override
    public EvaluateReply convert(EvaluateReplyRequest source) {
        EvaluateReply result = new EvaluateReply();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getParentReply()!=null){
                    EvaluateReply parentReply =new EvaluateReply();
                    parentReply.setId(source.getParentReply());
                    result.setParentReply(parentReply);
                    }
                    if(source.getReplyUser()!=null){
                    User replyUser =new User();
                    replyUser.setId(source.getReplyUser());
                    result.setReplyUser(replyUser);
                    }
                    if(source.getEvaluate()!=null){
                    Evaluate evaluate =new Evaluate();
                    evaluate.setId(source.getEvaluate());
                    result.setEvaluate(evaluate);
                    }
                    if(source.getTargetUser()!=null){
                    User targetUser =new User();
                    targetUser.setId(source.getTargetUser());
                    result.setTargetUser(targetUser);
                    }
        return result;
    }
}

